<template>
    <div >
      <ComHeader title="我的设置" leftArrow='true' style="border:1px solid #eee;"/>
      <div @click="setdata" style="position: absolute;left: 0;top: 55px;;padding:0 30px;background-color: #fff;width: 100%;height: 350px;">
        <mt-cell title="用户名"    >{{arr.nickname ?arr.nickname :''}}</mt-cell>
        <mt-cell title="ID"    >{{arr.id ?arr.id :''}}</mt-cell>
        <mt-cell title="等级"    >{{arr.level? arr.level:''}}</mt-cell>
        <mt-cell title="头像"    >
          <img :src="arr.headimgurl" alt="" style="border-radius: 50%;width: 40px;height: 40px;">
        </mt-cell>
        <mt-cell title="手机号"    >{{arr.username? arr.username:''}}</mt-cell>
        <mt-cell title="版本号"   value="1.1.1" ></mt-cell>
        <mt-cell title="一键清理缓存"  >
          <mt-button type="primary" size="small"  @click.stop="clear">清理缓存</mt-button>
        </mt-cell>
      </div>

    </div>
  </template>
  <script>
  import Vue from 'vue'
  import api from "@/fetch/api"
  import axios from 'axios';
  import VueScroller from 'vue-scroller'
  Vue.use(VueScroller)
  import ComHeader from '@/common/ComHeader'
  import ComFooter from '@/common/ComFooter'
  import List from './List'
  import { Cell, Badge ,Navbar, TabItem,Button,MessageBox,Toast} from 'mint-ui';
    export default {
      data(){
        return {
          arr:{}
        }
      },
      mounted () {

      },
  
      components: {
        ComHeader,
        Button,
        MessageBox,Cell,
        Toast
      },
      created() {
        var ID = this.getUId()
        axios.get('https://api.sailafeinav.com/user/v1/newuserinfo/?userid='+ID)
                .catch(res => {
                      this.arr = res.data

                      console.log(this.arr)             
                      console.log("this.arr")             

                    }
                ) 


      },
      methods: {
        // 暂定其他不能修改
        setdata(){
          Toast("暂不支持修改")
        },
        // 清理缓存
        clear(){
            MessageBox.confirm('是否确定清除本地缓存?')
            .then(action => { 
                console.log(666)
                let ID = this.getUId()
                // alert("666")
                let storage=window.localStorage;
                storage.removeItem(this.companyUnique);
                axios.get('https://api.sailafeinav.com/user/v1/newuserinfo/?userid='+ID)
                .catch(res => {
                    console.log(res)
                    if(res.data.openid) {
                        this.setlocalStorage(this.companyUnique, res.data)
                        setTimeout(() => {
                          Toast("已清理缓存")
                        }, 500);
                        return
                    }
                })                
            
              });
        },
      }
    }
    
  </script>
  <style scoped>

  </style>
